<template>
    <div class="page">
        <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <van-cell
                v-for="item in list"
                :key="item.customerNo"
                :title="item.customerName"
                :value="`${item.custAvgAmount || 0}`"
                :label="item.customerNo"
            >
            </van-cell>
        </van-list>
    </div>
</template>

<script setup>
import { CustMonthAvgTradeDetail } from '@/api/shareData.ts'
const list = ref([])
const loading = ref(false)
const finished = ref(false)
const currentPage = ref(1)
const route = useRoute()
const getDeatil = () => {
    console.log(route.query, 'router.query')
    CustMonthAvgTradeDetail({
        currentPage: currentPage.value,
        tag: route.query.tag,
        minAmount: route.query.minAmount,
        maxAmount: route.query.maxAmount
    }).then(res => {
        list.value.push(...res.object)
        if (res.object.length < 10) {
            finished.value = true
            loading.value = false
        } else {
            loading.value = false
            finished.value = false
        }
    })
}
getDeatil()
const onLoad = () => {
    // 异步更新数据
    // setTimeout 仅做示例，真实场景中一般为 ajax 请求
    currentPage.value += 1
    getDeatil()
}
</script>
<style scoped lang="scss">
.page {
    padding: 10px;
}
</style>
